package rcs34.android.AndroidRC;

import java.util.ArrayList;

public class IPRegister{
  private ArrayList<IPPermision> permisions=new ArrayList<IPPermision>();
  
  public class IPPermision {
    public String ip;
    public Boolean enabled;
    public IPPermision(String _ip, boolean _enabled){
      ip=_ip;
      enabled=_enabled;
    }
  }
  
  public Boolean get(String _ip){
    for(IPPermision perm:permisions){
      if(perm.ip.equals(_ip)){
        return perm.enabled;
      }
    }
    return null;
  }
  
  public IPPermision get(int _index){
    return permisions.get(_index);
  }
  
  public void clear(){
    permisions.clear();
  }
  
  public int size(){
    return permisions.size();
  }
  
  public void put(String _ip, boolean _permitted){
    for(IPPermision perm:permisions){
      if(perm.ip.equals(_ip)){
        perm.enabled=_permitted;
        return;
      }
    }
    permisions.add(new IPPermision(_ip, _permitted));
  }
}


